<?php
$g_name=isset($_GET['g_name'])?$_GET['g_name']:'';
$where='1';
if(empty($g_name))
{
    $where.=" and g_name like '%$g_name%'";
}
$page=isset($_GET['page'])?$_GET['page'] : 1;
$size=isset($_GET['limit'])?$_GET['limit']:3;

include_once "show1.php";
$dbh = new DBO('127.0.0.1','1705php', 'root','root');
$count=$dbh->getNumber('games',$where);//调用封装类的方法 得到总条数
$limit=($page-1)*$size;
$data=$dbh->getAll('games',$limit,$size,$where);//得到要查询数据
if($data)
{
    $arr['code']='0';
    $arr['msg']='成功';
    $arr['data']=$data;
    $arr['count']=$count;
    echo json_encode($arr);
}else
{
    $arr['code']='1';
    $arr['msg']='失败';
    $arr['data']='';
    $arr['count']='';
    echo json_encode($arr);
}
?>
